
from django.shortcuts import render,HttpResponse
from Models.models import Book
from django.core import serializers

class useGet():
    def index(request):
        books = Book.objects.get(pk=5)
        print(serializers.serialize('json',books))
        books = Book.objects.get(pk=18)  # 报错，没有符合条件的对象
        books = Book.objects.get(price=200)  # 报错，符合条件的对象超过一个
        print(books, type(books))  # 模型类的对象
        return HttpResponse("<p>查找成功！</p>")